<template>
  <div>
      <table algin="center">
          <tr v-for="i in msglist" :key="i.id">
              <td v-if="i.status==2" style="font-weight:900">
                  <van-button @click="msg(i.id,i.usertype)"> <font>{{i.title}}</font> </van-button>
              </td>
              <td v-else>
                  <van-button @click="msg(i.id,i.usertype)"> <font>{{i.title}}</font> </van-button>
              </td>

          </tr>
      </table>
  </div>
</template>
    
<script>
import axios from 'axios'
export default {
    name:'mymsg',
    data(){
        return{
            msglist:[],
            // uid:localStorage.getItem('uid')
            uid:2
        }
    },
    methods:{
        getmsg(){
            axios.get('/getmessage?userid='+this.uid).then(res=>{
                console.log(res);
                this.msglist = res.data.list
            })
        },
        msg(mid,usertype){
            
            axios.post('/getmessage',{'msgid':mid,'userid':this.uid,'usertype':usertype}).then(res=>{
                    console.log(res);
                    if(res.data.code == 200){
                        this.getmsg()
                    }
                })
            
        }
    },
    mounted(){
        this.getmsg()
    }
}
</script>

<style>
    .color{
     color: red;
    }
</style>